package whf.shop.entity;

public class OrderItem extends whf.framework.entity.AbstractEntity{

	private static final long serialVersionUID = 0;

	private whf.shop.entity.Product product;

	private whf.shop.entity.Order order;

	private int quantity;

	private double price;

	private double discount;

	//
	private double totalPrice;

	// ---------- methods ----------
	public OrderItem() {

	}

	public OrderItem(Product product, int quantity) {
		this.product = product;
		this.quantity = quantity;
		this.price = product.getPrice();
		this.discount = product.getDiscount();
	}

	public void setProduct(whf.shop.entity.Product product) {
		this.product = product;
	}

	public whf.shop.entity.Product getProduct() {
		return this.product;
	}

	public void setOrder(whf.shop.entity.Order order) {
		this.order = order;
	}

	public whf.shop.entity.Order getOrder() {
		return this.order;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public int getQuantity() {
		return this.quantity;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public double getPrice() {
		return this.price;
	}

	public void setDiscount(double discount) {
		this.discount = discount;
	}

	public double getDiscount() {
		return this.discount;
	}

	public double getTotalPrice() {
		return this.price * this.quantity * (1 - this.discount);
	}
}